<?php
session_start();
 $_SESSION['uid']="uid";
?>
<?php require_once 'data/user.php';?>
<?php
     echo "<center>";
    if (isset($_POST['submit'])):
?>

<?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    $isOK = FALSE;
    $index = -1;
    for ($i = 0; $i < count($users); $i++) {
    if ((strcmp($users[$i]['username'], $username) == 0) &&
        (strcmp($users[$i]['password'], $password) == 0)) {
         $isOK = TRUE;
         $index = $i;}}
         
    if ( $isOK ) {
      header("Location: http://localhost/votuananh-web1/file.php?uid=".$users[$index]['id']);
 }  else
 {    echo " <script> alert('dang nhap khong thanh cong')</script>";
 }?>

<?php endif; ?>

<html>
    <body>
        <center>
        <h1>login</h1>
        
        <h4>username:admin1</h4>
        <h4>password:123</h4>
        <form action="loginFilms.php" method="Post">
            <table>
                <tr><td><input "type="text" name="username"></td></tr>
                <tr><td><input type="password" name="password"></td></tr>
                <tr><td><input type="submit" name="submit" value="Enter"></td></tr>
            </table></form> </center>
    
     </body>
     </html>